/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.Model
*        文件名:             BaseItemsEntity.cs
*        创建系统时间:       2012/11/2 19:07:02
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.Model
{
    using System;
    using System.Data;
    using ECP.Utilities;

    [Serializable]
    public class BaseItemsEntity
    {
        private bool allowDelete;
        private bool allowEdit;
        private string code;
        private string createDate;
        private string createUserID;
        private string description;
        private bool enabled;
        private string fullName;
        private string id;
        private bool isTree;
        private string modifyDate;
        private string modifyUserID;
        private string parentID;
        private string sortCode;
        private string targetTable;
        private bool useItemCode;
        private bool useItemName;
        private bool useItemValue;

        public BaseItemsEntity()
        {
            this.useItemCode = true;
            this.useItemName = true;
            this.allowEdit = true;
            this.allowDelete = true;
            this.enabled = true;
        }

        public BaseItemsEntity(DataRow dataRow)
        {
            this.useItemCode = true;
            this.useItemName = true;
            this.allowEdit = true;
            this.allowDelete = true;
            this.enabled = true;
            this.GetFrom(dataRow);
        }

        public BaseItemsEntity(DataTable dataTable)
        {
            this.useItemCode = true;
            this.useItemName = true;
            this.allowEdit = true;
            this.allowDelete = true;
            this.enabled = true;
            this.GetFrom(dataTable);
        }

        public BaseItemsEntity GetFrom(DataRow dataRow)
        {
            this.ID = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldID]);
            this.ParentID = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldParentID]);
            this.Code = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldCode]);
            this.FullName = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldFullName]);
            this.TargetTable = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldTargetTable]);
            this.IsTree = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseItemsTable.FieldIsTree]);
            this.UseItemCode = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseItemsTable.FieldUseItemCode]);
            this.UseItemName = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseItemsTable.FieldUseItemName]);
            this.UseItemValue = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseItemsTable.FieldUseItemValue]);
            this.AllowEdit = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseItemsTable.FieldAllowEdit]);
            this.AllowDelete = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseItemsTable.FieldAllowDelete]);
            this.Description = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldDescription]);
            this.Enabled = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseItemsTable.FieldEnabled]);
            this.SortCode = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldSortCode]);
            this.CreateDate = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldCreateDate]);
            this.CreateUserID = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldCreateUserID]);
            this.ModifyDate = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldModifyDate]);
            this.ModifyUserID = BaseBusinessLogic.ConvertToString(dataRow[BaseItemsTable.FieldModifyUserID]);
            return this;
        }

        public BaseItemsEntity GetFrom(DataTable dataTable)
        {
            if ((dataTable == null) || (dataTable.Rows.Count == 0))
            {
                return null;
            }
            foreach (DataRow row in dataTable.Rows)
            {
                this.GetFrom(row);
                break;
            }
            return this;
        }

        public bool AllowDelete
        {
            get
            {
                return this.allowDelete;
            }
            set
            {
                this.allowDelete = value;
            }
        }

        public bool AllowEdit
        {
            get
            {
                return this.allowEdit;
            }
            set
            {
                this.allowEdit = value;
            }
        }

        public string Code
        {
            get
            {
                return this.code;
            }
            set
            {
                this.code = value;
            }
        }

        public string CreateDate
        {
            get
            {
                return this.createDate;
            }
            set
            {
                this.createDate = value;
            }
        }

        public string CreateUserID
        {
            get
            {
                return this.createUserID;
            }
            set
            {
                this.createUserID = value;
            }
        }

        public string Description
        {
            get
            {
                return this.description;
            }
            set
            {
                this.description = value;
            }
        }

        public bool Enabled
        {
            get
            {
                return this.enabled;
            }
            set
            {
                this.enabled = value;
            }
        }

        public string FullName
        {
            get
            {
                return this.fullName;
            }
            set
            {
                this.fullName = value;
            }
        }

        public string ID
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id = value;
            }
        }

        public bool IsTree
        {
            get
            {
                return this.isTree;
            }
            set
            {
                this.isTree = value;
            }
        }

        public string ModifyDate
        {
            get
            {
                return this.modifyDate;
            }
            set
            {
                this.modifyDate = value;
            }
        }

        public string ModifyUserID
        {
            get
            {
                return this.modifyUserID;
            }
            set
            {
                this.modifyUserID = value;
            }
        }

        public string ParentID
        {
            get
            {
                return this.parentID;
            }
            set
            {
                this.parentID = value;
            }
        }

        public string SortCode
        {
            get
            {
                return this.sortCode;
            }
            set
            {
                this.sortCode = value;
            }
        }

        public string TargetTable
        {
            get
            {
                return this.targetTable;
            }
            set
            {
                this.targetTable = value;
            }
        }

        public bool UseItemCode
        {
            get
            {
                return this.useItemCode;
            }
            set
            {
                this.useItemCode = value;
            }
        }

        public bool UseItemName
        {
            get
            {
                return this.useItemName;
            }
            set
            {
                this.useItemName = value;
            }
        }

        public bool UseItemValue
        {
            get
            {
                return this.useItemValue;
            }
            set
            {
                this.useItemValue = value;
            }
        }
    }
}